package org.jboss.as.quickstarts.poh5helloworld;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.ws.rs.Produces;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import static javax.ws.rs.core.MediaType.*;

/**
 *
 * @author moroz
 */
@Provider
@Produces(APPLICATION_XML)
public class MapResolver implements ContextResolver<JAXBContext> {

    private JAXBContext ctx;
    
    public MapResolver() throws JAXBException{
        ctx=JAXBContext.newInstance(ConcurrentHashMap.class);
    }

    @Override
    public JAXBContext getContext(Class<?> type) {
        if (type.equals(Map.class)) {
            return ctx;
        } else {
            return null;
        }
    }
}
